home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 June / ccd0605.iso / Software / Complet / The Gimp / gimp-2.2.7-i586-setup.exe / {app} / share / gimp / 2.0 / scripts / guides-new-percent.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2005-05-09  |  1.3 KB  |  41 lines

  1. ;; -*-scheme-*-
  2.  
  3. ;; Alan Horkan 2004.  Copyright.  
  4. ;; I'll fix it and license it differntly later if anyone cares to ask
  5.  
  6. (define (script-fu-guide-new-percent image
  7.                      drawable
  8.                      direction
  9.                      position)
  10.   (let* ((width (car (gimp-drawable-width drawable)))
  11.      (height (car (gimp-drawable-height drawable))))
  12.     (gimp-image-undo-group-start image)
  13.  
  14.     (if (= direction 0)
  15.     (set! position (/ (* height position) 100))
  16.     (set! position (/ (* width position) 100)))
  17.  
  18.     (if (= direction 0) 
  19.     ;; convert position to pixel 
  20.     (if (< position height) (gimp-image-add-hguide image position))
  21.     (if (< position width) (gimp-image-add-vguide image position)))
  22.  
  23.     (gimp-image-undo-group-end image)
  24.     (gimp-displays-flush)))
  25.     
  26. (script-fu-register "script-fu-guide-new-percent"
  27.             _"New Guide (by _Percent)..." 
  28.             "Add a single Line Guide with the specified postion. Position specified as a percent of the image size."
  29.             "Alan Horkan"
  30.             "Alan Horkan, 2004"
  31.             "April 2004"
  32.             ""
  33.             SF-IMAGE      "Input Image"      0 
  34.             SF-DRAWABLE   "Input Drawable"   0
  35.             SF-OPTION     _"Direction"       '(_"Horizontal" 
  36.                                _"Vertical")
  37.             SF-ADJUSTMENT _"Position (in %)" '(50 0 100 1 10 0 1))
  38.     
  39. (script-fu-menu-register "script-fu-guide-new-percent"
  40.              "<Image>/Image/Guides")
  41.